/*
 * Created: 2022-09-12 19:09:03
 * Author : 涛涛涛
 */

import React, { FC } from 'react';
import { styled } from 'linaria/react';
import { useClassName } from '@/utils/index';
import { View } from '@tarojs/components';
import CardTitle from '@/pages/HomeSearch/components/CardTitle/CardTitle';
import OptionTagList from './OptionTagList/OptionTagList';
import OptionTagItem from './OptionTagItem/OptionTagItem';
export interface IProps extends ICompProps {
    /** 标题 */
    title: string;
    /** 选项 */
    options: string[];
    /** 点击选项的回调 */
    onSelect: (words: string) => void;
    /** 数据加载中 */
    isLoading: boolean;
}
RecordList.defaultProps = {} as Partial<IProps>;
function RecordList(props: IProps) {
    const { className, style, title, options, onSelect } = props;
    const localClassName = useClassName('RecordList', className);
    return (
        <RootRecordCard className={localClassName} style={style}>
            <CardTitle>{title}</CardTitle>
            <OptionTagList>
                {options.map((opt) => (
                    <OptionTagItem key={opt} onClick={() => onSelect(opt)}>
                        {opt}
                    </OptionTagItem>
                ))}
            </OptionTagList>
        </RootRecordCard>
    );
}
export default React.memo(RecordList as FC<IProps>);
const RootRecordCard = styled(View)`
    &.RecordList {
    }
`;
